import type { App } from "vue";
import { useUserInfoStore } from "@/stores/userInfo";
const registerPermissionDirective = (app: App) => {
  // 注册（函数形式的指令）
  app.directive("permission", (el, binding) => {
    const userInfoStore = useUserInfoStore();
    // 如果指令的内容不包含在按钮权限中，则移出按钮
    if (!userInfoStore.buttons.includes(binding.value)) {
      el.remove();
    }
  });
};
// 默认导出
export default registerPermissionDirective;
